package com.teamwhole.modules.sys.entity;

import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.google.common.collect.Lists;
import com.teamwhole.core.persistence.BaseEntity;

public class User extends BaseEntity<User>{
	
	private static final long serialVersionUID = 1L;
	
	private String	loginName;      // 用户名
	private String	password;       // 密码
	private String	name;           // 姓名
	private String	phone;          // 手机
	private String	email;          // 邮箱
	private String	loginIp;        // 最后登陆IP
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date	loginDate;      // 最后登陆日期
	private Department dept;        // 所属部门
	private String	position;		// 职位信息
	private String	remarks;        // 备注
	private List<Role> roleList = Lists.newArrayList();// 角色列表
	
	public User(){
	}
	public User(String id){
		super(id);
	}
	public User(String id, String loginName){
        super(id);
        this.loginName = loginName;
    }
    public String getPosition() {
		return position;
	}
	public void setPosition(String position) {
		this.position = position;
	}
	public List<Role> getRoleList() {
		return roleList;
	}
	public void setRoleList(List<Role> roleList) {
		this.roleList = roleList;
	}
	public String getRemarks() {
		return remarks;
	}
	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}
	public Department getDept() {
		return dept;
	}
	public void setDept(Department dept) {
		this.dept = dept;
	}
	public String getLoginName() {
		return loginName;
	}
	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getLoginIp() {
		return loginIp;
	}
	public void setLoginIp(String loginIp) {
		this.loginIp = loginIp;
	}
	public Date getLoginDate() {
		return loginDate;
	}
	public void setLoginDate(Date loginDate) {
		this.loginDate = loginDate;
	}
	public boolean isAdmin(){
		return isAdmin(this.id);
	}
	public static boolean isAdmin(String id){
		return id != null && "1".equals(id);
	}
	public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    @Override
	public String toString() {
		return id;
	}
}